package com.unisound.tracelog.server.ui.controller;

import com.unisound.tracelog.common.model.dto.ResultDTO;
import com.unisound.tracelog.common.model.pojo.PageResult;
import com.unisound.tracelog.server.ui.model.request.MainTraceLogSearchRequest;
import com.unisound.tracelog.server.ui.model.request.TraceLogListPageRequest;
import com.unisound.tracelog.server.ui.model.request.TraceLogSearchChildrenRequest;
import com.unisound.tracelog.server.ui.model.request.TraceLogSearchRequest;
import com.unisound.tracelog.server.ui.model.response.ExportJsonResponse;
import com.unisound.tracelog.server.ui.model.response.TraceLogResponse;
import com.unisound.tracelog.server.ui.service.UITraceLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ui/tracelog")
public class UITracelogController {

    @Autowired
    private UITraceLogService uiTraceLogService;

    @RequestMapping("/search-main")
    public ResultDTO<PageResult<TraceLogResponse>> searchMain(@RequestBody MainTraceLogSearchRequest request) {
        return uiTraceLogService.searchMain(request);
    }

    @RequestMapping("/search")
    public ResultDTO<TraceLogResponse> search(@RequestBody TraceLogSearchRequest request) {
        return uiTraceLogService.search(request);
    }

    @RequestMapping("/search-children")
    public ResultDTO<TraceLogResponse> searchChildren(@RequestBody TraceLogSearchChildrenRequest request) {
        return uiTraceLogService.searchChildren(request);
    }

    @RequestMapping("/exportJson")
    public ResultDTO<ExportJsonResponse> exportJson(@RequestBody TraceLogSearchRequest request) {
        return uiTraceLogService.exportJson(request);
    }

    @RequestMapping("/list-page")
    ResultDTO<PageResult<TraceLogResponse>> listPage(@RequestBody TraceLogListPageRequest request) {
        return uiTraceLogService.listPage(request);
    }

}
